<div class="right_panel {{showbar&&'focus'}}">
    <div class="tools_bar">
        <div class="tools_bar_a" ></div>
        <div class="tools_bar_b" event-click="{{'$Event.showbar'}}" event-click-new="{{'$Event.Show_Map'}}"></div>
        <div class="tools_bar_c"><div class="tools_bar_c_txt">购物车</div></div>
        <tool_bar bar_class="icon-heart2" bar_title="我的喜爱"></tool_bar>
        <tool_bar bar_class="icon-coin" bar_title="我的积分"></tool_bar>
        <tool_bar bar_class="icon-star" bar_title="我的收藏"></tool_bar>
        <tool_bar event_click="$Event.open_chat_window" bar_class="icon-bubble2" bar_title="我的消息"></tool_bar>
        <tool_bar bar_class="icon-map" bar_title="周边地图"></tool_bar>
        <tool_bar bar_title="点纳主页"></tool_bar>
        <tool_bar event_click="$Event.Scroll_top" bar_class="icon-arrow-up" bar_title="返回头部"></tool_bar>
        
    </div>
    <div class="box">
        <div class="imbox">
            <div class="map_bounds_box">
                <div class="map_keys">
                	<!-- <div>
                    	<button class="bigmapbtn" event-click="{{'$Event.show_map_big'}}"><i class="icon-expand"></i>{{$Big_Map&&'收起'||'查看'}}大地图</button>
                	</div> -->
                    <select bind-value="{{$Cache_search_map_key}}" bind-input="{{'$Cache_search_map_key'}}">
                        <option>酒店</option>
                        <option>饭馆</option>
                        <option>KTV</option>
                        <option>超市</option>
                    </select>
                    <button event-click="{{'$Event.map_search'}}">查找</button>
                </div>
                <div id="map_bounds">
                </div>
            </div>
        </div>
        <div class="bmap" id="allmap">
        </div>
    </div>

</div>

{{#include "/pages/_chat.html"}}

<xmp type="tag" name="tool_bar">
    <div class="tools_bar_d">
        <label event-click="{{'${event_click}'}}" id="${bar_id}" bind-class="${bar_class}" title="${bar_title}"></label>
        <div class="bar_buff">${bar_title}
            <div class="triangle-right"></div>
        </div>
    </div>
</xmp>
        
<!-- <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=Noga0lSLMrk62roymqXkgaUB"></script> -->
<script type="text/vm">
function() {
	// 显示侧边栏
	App.set("$Event.showbar", function() {
		App.model.toggle("showbar");
	});
	// 返回顶部
	App.set("$Event.Scroll_top", function() {
		$(".index_body").animate({
			scrollTop: 0
		}, 200);
	});
	// 周边搜索
	App.set("$Event.map_search", function() {
		var search_map_key = App.get("$Cache_search_map_key");
		if (!search_map_key) {
			search_map_key = "酒店";
		};
		var local = App.get("$Cache_Map_Local");
		local.searchNearby(search_map_key, App.get("$Cache_Map_Local_City"));
	});

	// 打开会话框
	App.set("$Event.open_chat_window",function(){
		App.model.toggle("$Cache_open_chat_window");
	});

	// 地图模板
	function init_map(keys) {
		var init_map_create = setInterval(function() {
			if (window.BMap) {
				map = new BMap.Map("allmap"); // 创建Map实例
				map.enableScrollWheelZoom(); //启用滚轮放大缩小
				var myCity = new BMap.LocalCity();
				myCity.get(function(result) {
					console.log(result)
					cityName = result.name;
					var point = new BMap.Point(result.center.lng, result.center.lat);
					map.centerAndZoom(point, 12);
					local = new BMap.LocalSearch(map, {
						renderOptions: {
							map: map,
							panel: "map_bounds"
						},
						pageCapacity: 9
					});
					local.searchNearby(keys, cityName);
					App.set("$Cache_Map_Local", local);
					App.set("$Cache_Map_Local_City", cityName);
					return local;
				});
				clearInterval(init_map_create);
			};
		});
	}
	// 首次加载地图
	var init_map_flag = false;
	App.set("$Event.Show_Map", function() {
		if (!init_map_flag) {
			init_map("酒店");
			init_map_flag = true;
		}
	})
}
</script>